package com.hequ.merchant.banner.api;

import com.hequ.merchant.banner.entity.Module;
import com.hequ.merchant.banner.handler.ModuleJsonResponseHandler;

import org.json.JSONException;

import java.util.List;

/**
 * Created by 柯尊诚 on 2015/10/23.
 * kzc
 */
public class ModuleListRequest extends BannerRequest<List<Module>>{

    private ModuleJsonResponseHandler handler = new ModuleJsonResponseHandler();


    public ModuleListRequest(OnRequestListener<List<Module>> listener) {
        super(Method.GET, "/modules", listener);
    }

    @Override
    public List<Module> parseResponse(String result) {
        try {
            handler.parse(result);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return handler.getParsedItems();
    }
}
